#include <iostream>
#include "Buffer.hpp"




#ifdef BUFFER_TEST 
int main(){

    //基础读写功能的测试
    /* Buffer buf;
    std::string str = "wohaoleiaaaaa";
    buf.WriteByString(str);

    std::cout << "buf当前可读空间" << buf.ReadableSize() << std::endl;
    std::cout << "buf当前可写空间" << buf.WritableSize() << std::endl;

    std::cout << "buf当前读位置" << buf.ReadPos() << std::endl;


    std::string tmp = buf.ReadAsString(5);
    std::cout << "tmp : " << tmp << std::endl;

    std::cout << "buf当前可读空间" << buf.ReadableSize() << std::endl;
    std::cout << "buf当前可写空间" << buf.WritableSize() << std::endl;

    std::cout << "buf当前读位置" << buf.ReadPos() << std::endl;


    Buffer buf1;
    buf1.WriteByBUffer(buf);
    std::string s = buf1.ReadAsString(buf1.ReadableSize());
    
    std::cout << "buf1读取出来的 : " << s << std::endl;  
    std::cout << "buf1当前可读空间" << buf1.ReadableSize() << std::endl;
    std::cout << "buf1当前可写空间" << buf1.WritableSize() << std::endl; */

    
    //测试扩容是否合理
    /* Buffer buf;
    std::string s;
    for(int i = 0; i < 1025; ++i) s += std::to_string(i);
    buf.WriteByString(s);

    std::cout << "写入后 可读空间" << buf.ReadableSize() << std::endl;
    std::cout << "写入后 可写空间" << buf.WritableSize() << std::endl;
    
    //全部读取出来
    std::string res = buf.ReadAsString(buf.ReadableSize());

    std::cout << "读取后 可读空间" << buf.ReadableSize() << std::endl;
    std::cout << "读取后 可写空间" << buf.WritableSize() << std::endl; */



    //最后测试读取一行数据
    char data[] = "asdbkadsnmdaslkad\r\n";
    Buffer buf;
    buf.Write(data, sizeof(data));

    std::cout << "data写入后 可读空间" << buf.ReadableSize() << std::endl;
    std::cout << "data写入后 可写空间" << buf.WritableSize() << std::endl;

    std::string oneline = buf.GetOneLine();
    std::cout << "getoneline : " << oneline << std::endl;

    std::cout << buf.ReadPos() << std::endl;

    std::cout << "data读取后 可读空间" << buf.ReadableSize() << std::endl;
    std::cout << "data读取后 可写空间" << buf.WritableSize() << std::endl;

    return 0;
}
#endif